package com.example.blog.hander;

import com.example.blog.vo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

// 拦截加了 @Controller 注解的方法进行拦截处理 AOP的实现
@ControllerAdvice
@Slf4j
public class AllExceptionHandler {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result doException(Exception ex) {
           ex.printStackTrace();
           return Result.fail(-999, "系统异常");
    }

}
